package com.edu.zql;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by User on 2017/10/13.
 */
public class ThreadPriority {


    public static void main(String[] args) {

        List<Thread> threadList = new ArrayList();

        for (int i = 0; i < 10; i++) {
            final int t = i;
            Thread thread = new Thread(() -> {
                long startTime = System.currentTimeMillis();
                String s = "";
                for (int j = 0; j < 10000 + (1000 * t); j++) {
                    s += j + ",";
                }
                long endTime = System.currentTimeMillis();
                System.out.println(Thread.currentThread().getName() + "消耗时间为：" + (endTime - startTime));
            });
            thread.setPriority(i + 1);  // 最小值为1 最大值10
            thread.setName("优先级为" + (i + 1) + "的线程");

            threadList.add(thread);
        }


        for (Thread thread : threadList) {
            thread.start();
        }


    }









}
